package cn.gjculture.shopping.api.util;


import org.apache.commons.codec.digest.DigestUtils;

import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;

public class UUIDUtil {
    static AtomicLong atomicLong=new AtomicLong();

    public static Long getID(){
        Long date=Long.valueOf(DateUtils.getDate("yyyyMMddHHmmssS"));
        return date+atomicLong.incrementAndGet();
    }

    public static String getUUID(){
        return UUID.randomUUID().toString().replace("-","");
    }
    public static String[] getUUID(int count){
        if(count<=0){
            return null;
        }
        String[] uuids=new String[count];
        for(int i=0;i<count;i++){
            uuids[i]=UUID.randomUUID().toString().replace("-","");
        }
        return uuids;
    }

    public static String sha256(String str){
        return DigestUtils.sha256Hex(str);
    }

    public static String getPrivateKey(){
        return sha256(getUUID());
    }



    public static String encrypt(String str){
        return DigestUtils.md5Hex(str);
    }

    public static void main(String[] args) {
//        for(int i=0;i<100;i++){
//            System.out.println(getID());
//        }
//        System.out.println(getUUID());
//        System.out.println(getUUID().length());
//        String ss=new String(DigestUtils.sha256Hex(getUUID()));
//        System.out.println(ss);
//        System.out.println(ss.length());

        System.out.println(encrypt("123456"));
//        System.out.println(encrypt("123456").length());

//        ParamData<Goods> param=new ParamData<>();
//        param.getCommon().setToken("46124521452415");
//        param.getCommon().setCustomerId("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
//        param.getCommon().setTimestamp(System.currentTimeMillis());
//        param.setSign("aaasdflkjlkjklj;jk;lnlnjhksdafa14222222222222");
//        param.getPage().setCurrentPage(0);
//        param.getPage().setOrderBy("goodsId");
//        param.getPage().setPageSize(20);
//        param.setData(new Goods());
//        System.out.println(JSONObject.toJSONString(param));
    }
}
